<template>
    <rx-dialog @handOk="onOk" @cancel="onCancel">
        <rx-layout>
            <div slot="center">
                <a-tabs>
                    <a-tab-pane key="nextFunc" :tab="i18n('list.extFunc','下一步扩展函数')" forceRender>
                        <rx-monaco-editor
                            ref="nextFunc"
                            v-model="nextFunc"
                            language="javascript"
                            style="height:300px;"
                        >
                        </rx-monaco-editor>
                        <div style="line-height: 14px;margin-top: 10px;">
                            <p>{{i18n('msg.extTip1','说明:当点击下一步时,需执行的脚本')}}</p>
                            <p>{{i18n('msg.param','参数')}}:</p>
                            <p style="margin-left: 20px;">formData：{{i18n('msg.extTip2','当前表单数据,自定义页面无此参数')}}</p>
                            <p style="margin-left: 20px;">busFormData：{{i18n('msg.extTip3','全部表单数据')}}</p>
                        </div>
                    </a-tab-pane>
                    <a-tab-pane key="condition" forceRender :disabled="isMain || lastOne">
                        <div slot="tab"  v-show="!isMain && !lastOne">
                            {{i18n('list.skip','跳过条件')}}
                        </div>
                        <rx-monaco-editor
                            v-if="!isMain"
                            ref="condition"
                            v-model="condition"
                            language="javascript"
                            style="height:300px;"
                        >
                        </rx-monaco-editor>
                        <div style="line-height: 14px;margin-top: 10px;">
                            <p>{{i18n('msg.skipTip1','说明:根据条件确定当前表单或页面是否跳过')}}</p>
                            <p>{{i18n('msg.param','参数')}}:</p>
                            <p style="margin-left: 20px;">busFormData：{{i18n('msg.extTip3','全部表单数据')}}</p>
                        </div>
                    </a-tab-pane>
                </a-tabs>
            </div>
        </rx-layout>
    </rx-dialog>
</template>

<script>
import {RxLayout, RxDialog, Util, RxMonacoEditor} from "@lowcode/jpaas-common-lib";

export default {
    name: "solExtendFunc",
    components: {
        RxLayout, RxDialog, RxMonacoEditor
    },
    props: {
        rowData: Object,
        lastOne: {
            type:Boolean,
            default:false
        },
        layerid: String,
        destroy: Function
    },
    data() {
        return {
            condition: "return false;",  //跳过条件
            nextFunc:"",
            isMain:false
        }
    },
    created() {
        this.isMain=this.rowData.isMain;
        if(this.rowData.extendFunc){
            var extendFunc = JSON.parse(this.rowData.extendFunc);
            this.condition=extendFunc.condition || "return false;";
            this.nextFunc=extendFunc.nextFunc || "";
        }
    },
    methods: {
        i18n(name,text,key){
            return this.$ti18(name,text,"formBusinessSolution",key);
        },
        onOk() {
            var data={
                condition:this.condition,
                nextFunc:this.nextFunc,
            }
            Util.closeWindow(this, 'ok',data);
        },
        onCancel() {
            Util.closeWindow(this, 'cancel');
        }
    }
}
</script>

<style scoped>

</style>